from flask import request, current_app, jsonify
import json

def register_config(bp):

    ## 配置更新
    @bp.route('/config/update')
    def update():
        #TODO
        pass

    
    @bp.route('/config/get')
    def get():
        ## 获取系统配置
        key = request.args.get('key')
        if not key:
            return jsonify({"message":"need key parameter"})
        else:
            result = current_app.config['DB'].get_config(key)
            return jsonify({"code":0, "data":json.loads(result)})

